package com.example.positioning.pojo;

import javafx.geometry.Point2D;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;

@Component
public class Room {
    Point2D zero=new Point2D(114.40473057321636,30.52916060119178);
    Point2D one=new Point2D(114.4047709969643,30.52916060119178);

    public Point2D getZero() {
        return zero;
    }

    public Point2D getOne() {
        return one;
    }

    public double angle=0;

    @PostConstruct
    public void init(){
        getAngle();
        System.out.println("房间角度："+PtoA(angle));
    }
    private double AtoP(Double angle){
        return angle/180*Math.PI;
    }
    private double PtoA(Double PI){
        return PI/Math.PI*180;
    }
    public void getAngle(){
        double xcha=one.getX()-zero.getX();
        double ycha=one.getY()-zero.getY();
        angle= Math.atan2(ycha,(xcha*Math.cos(AtoP(one.getY()))));
        if(ycha<0)angle+=Math.PI*2;
    }
}


